<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件</title>
</head>

<body>
    <input type="text">

    <script>
        const input = document.querySelector('input[type = text]')

        input.addEventListener('keydown', function () {
            console.log('键盘按下 ~')
        })

        input.addEventListener('keyup', function () {
            console.log('键盘弹起 ~');
        })

        input.addEventListener('input',function() {
            console.log('有文本输入 ~' + input.value);
        })
    </script>
</body>

</html>